<!DOCTYPE html>
<html lang="en">
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title th:text="${application.seoConfig.page['mh-search.title']}"></title>

    <meta name="keywords" th:content="${application.seoConfig.page['mh-search.keyword']}">

    <meta name="description"
          th:content="${application.seoConfig.page['mh-search.description']}">

    <div th:include="common/css :: css"></div>

    </div>

    <style type="text/css">


        .line-limit-length {

            overflow: hidden;

            text-overflow: ellipsis;

            white-space: nowrap;

        }

        .indexP p a {
            color: #4c6978;
        }

        .Readarea {
            font-size: 18px;
            line-height: 35px;
            padding: 10px;
            color: #333;
        }

        div, p {
            wrap-work: break-word;
            word-break: break-all;
            word-wrap: break-word;
            word-break: normal;
            -moz-box-sizing: border-box;
            -webkit-box-sizing: border-box;
            box-sizing: border-box;
            -ms-box-sizing: border-box;
        }

        .indexDiv a {
            margin-left: 20px;
        }

        img {
            width: 147px;
            height: 197px;
        }
    </style>
</head>
<body>


<input type="hidden" id="limit" th:value="${limit}"/>
<input type="hidden" id="curr" th:value="${curr}"/>
<input type="hidden" id="total" th:value="${total}"/>
<input type="hidden" id="ids" th:value="${ids}"/>
<input type="hidden" id="keyword" th:value="${keyword}"/>
<input type="hidden" id="softTag" th:value="${softTag}"/>
<input type="hidden" id="sortBy" th:value="${sortBy}"/>
<input type="hidden" id="sort" th:value="${sort}"/>
<input type="hidden" id="bookStatus" th:value="${bookStatus}"/>
<input type="hidden" id="softCat" th:value="${softCat}"/>

<ul class="layui-nav"  lay-filter="" style="padding:0 20px;text-align: center" >
    <li id="menunew" class="layui-nav-item"><a href="/book/searchSoftBook.html?catId=9">最新</a></li>
    <li id="menu21" class="layui-nav-item"><a href="/book/searchSoftBook.html?catId=9&softCat=3262">少年漫</a></li>
    <li id="menu22" class="layui-nav-item"><a href="/book/searchSoftBook.html?catId=9&softCat=3263">少女漫</a></li>
    <li id="menucomplete" class="layui-nav-item"><a >完本</a>
        <dl class="layui-nav-child"> <!-- 二级菜单 -->
            <dd><a href="/book/searchSoftBook.html?catId=9&bookStatus=已完成">全部</a></dd>
            <dd><a href="/book/searchSoftBook.html?catId=9&bookStatus=已完成&softCat=3262">少年漫</a></dd>
            <dd><a href="/book/searchSoftBook.html?catId=9&bookStatus=已完成&softCat=3263">少女漫</a></dd>
        </dl>
    </li>
    <li id="menuhot" class="layui-nav-item"><a >排行</a>
        <dl class="layui-nav-child"> <!-- 二级菜单 -->
            <dd><a href="/book/searchSoftBook.html?catId=9&sortBy=score">全部</a></dd>
            <dd><a href="/book/searchSoftBook.html?catId=9&sortBy=score&softCat=3262">少年漫</a></dd>
            <dd><a href="/book/searchSoftBook.html?catId=9&bookStatus=已完成&softCat=3263">少女漫</a></dd>
        </dl>
    </li>

</ul>


<div class="layui-container">
    <div class="layui-row">

        <div class="layui-col-xs10 layui-col-sm10 layui-col-md11 layui-col-lg11" style="padding-top:1%">
            <input id="title" type="text" name="title" required lay-verify="required" placeholder="请输入书名·作者"
                   autocomplete="off"
                   class="layui-input" th:value="${keyword}">
        </div>
        <div class="layui-col-xs1" style="padding: 1%">
            <button onclick="searchBooks()" class="layui-btn" lay-submit lay-filter="formDemo">搜索</button>
        </div>
    </div>

</div>


<div th:each="book : ${books}" class="layui-row" style="margin-bottom:10px;padding:10px;background: #f2f2f2">
    <a th:href="'/book/'+ ${book.id} + '.html'">
    <div class="layui-col-xs6 layui-col-sm3 layui-col-md2 layui-col-lg2" style="text-align: center" th:switch = "${application.noLazy}">
        <img th:case="'1'" align="center"
              th:attr="data-src=${book.picUrl}"/>
        <img th:case="*" align="center"
             class="lazyload" th:attr="data-src=${book.picUrl}"/>
    </div>
    </a>
    <div style="padding: 20px" class="layui-col-xs6 layui-col-sm8 layui-col-md8 layui-col-lg8">
        <a th:href="'/book/'+ ${book.id} + '.html'">
            <div class="line-limit-length" style=";color: #4c6978;font-weight: bold;font-size: 15px"
                 th:text="${book.bookName}"></div>
        </a>
        <div style=";color: #4c6978;float: right;"><i style="color: red" th:text="${book.score} + '分'"></i></div>
        <a th:href="'/book/searchSoftBook.html?catId=9&keyword='+ ${book.author}">
            <div style=";color: #4c6978;" class="line-limit-length" th:text="'作者：'+ ${book.author}"></div>
        </a>
        <div style="margin-top: 5px;color: #4c6978;" th:text="'类别：'+ ${book.cateName}"></div>
        <div style="margin-top: 5px;color: #4c6978;" th:text="'状态：'+ ${book.bookStatus}"></div>
        <div style="margin-top: 5px;color: #4c6978;">更新：<i th:text="${#dates.format(book.updateTime, 'yy-MM-dd')}"></i>
        </div>
        <div class="layui-collapse" style="margin-top: 5px;">
            <div class="layui-colla-item">
                <h2 style="color: #4c6978;" class="layui-colla-title">简介：</h2>
                <div style="color: #4c6978;" class="layui-colla-content" th:utext="${book.bookDesc}">

                </div>
            </div>
        </div>


    </div>

</div>


<div id="books" style="text-align: center"></div>


<div th:replace="common/soft_footer :: footer">
</div>

<a name="buttom"></a>
</body>

<div th:replace="common/js :: js"></div>
<script src="/js/lazyload.js"></script>

<script>
    lazyload();
    layui.use('laypage', function () {
        var laypage = layui.laypage;

        //执行一个laypage实例
        laypage.render({
            elem: 'books' //注意，这里的 test1 是 ID，不用加 # 号
            , count: $("#total").val() //数据总数，从服务端得到,
            , curr: $("#curr").val()
            , limit: $("#limit").val()
            , jump: function (obj, first) {


                //obj包含了当前分页的所有参数，比如：
                console.log(obj.curr); //得到当前页，以便向服务端请求对应页的数据。
                console.log(obj.limit); //得到每页显示的条数


                //首次不执行
                if (!first) {
                    searchByAllCondition(obj.curr,obj.limit);
                } else {

                }
            }
        });
    });

    function searchByAllCondition(curr,limit,newKeyword){
        var toUrl = "/book/searchSoftBook.html?catId=9&curr=" + curr + "&limit=" + limit;
        var ids = $("#ids").val();
        if(ids){
            toUrl += ("&historyBookIds=" + ids);
        }
        var keyword = $("#keyword").val();
        if(newKeyword){
            toUrl += encodeURI("&keyword=" + newKeyword);
        }else if (keyword) {
            toUrl += encodeURI("&keyword=" + keyword);
        }
        var bookStatus = $("#bookStatus").val();
        if(bookStatus){
            toUrl += ("&bookStatus=" + bookStatus);
        }
        var softCat = $("#softCat").val();
        if (softCat) {
            toUrl += ("&softCat=" + softCat);
        }
        var softTag = $("#softTag").val();
        if (softTag) {
            toUrl += ("&softTag=" + softTag);
        }

        var sortBy = $("#sortBy").val();
        if (sortBy) {
            toUrl += ("&sortBy=" + sortBy);
        }

        var sort = $("#sort").val();
        if (sort) {
            toUrl += ("&sort=" + sort);
        }

        window.location.href = toUrl;
    }

    function searchBooks() {
        var keywords = $("#title").val();
        $("#keyword").val("");
        searchByAllCondition(1,20,keywords);
    }

</script>
<script>
    (function(){


        var sortCat = $("#softCat").val();
        var sortBy = $("#sortBy").val();
        if(sortBy == 'score'){
            $("#menuhot").addClass("layui-this");
        }else if($("#bookStatus").val()){
            $("#menucomplete").addClass("layui-this");
        }else if(sortCat){
            $("#menu"+sortCat).addClass("layui-this");
        }else{
            $("#menunew").addClass("layui-this");
        }

    })();


    function toMyCollect(){
        var token = localStorage.getItem("token");
        if(token) {
            window.location.href = "/book/search?token=" + token;
        }else{
            window.location.href = "/user/login.html";
        }
    }
</script>



</html>